using UnityEngine;
using UnityEngine.UI;

namespace Hydrogen.ULib.UINavigation
{
    [RequireComponent(typeof(UINavGroup))]
    public class UIButtonGroup : UISelectableBase,
        IUINavGroupPushedHandle,
        IUINavGroupPopedHandle
    {
        private Image _bg
        {
            get
            {
                if (!m_bg) m_bg = GetComponent<Image>();
                return m_bg;
            }
        }
        private Image m_bg;

        void IUINavGroupPushedHandle.OnPushed(IUINavHandle parent)
        {
            if (!this._bg) return;
            if (!ColorUtility.TryParseHtmlString("#00C9FF9E", out Color color)) return;
            this._bg.color = color;
        }

        void IUINavGroupPopedHandle.OnPoped()
        {
            if (!this._bg) return;
            if (!ColorUtility.TryParseHtmlString("#FFFFFF64", out Color color)) return;
            this._bg.color = color;
        }

        protected override Color GetFKColor() => Color.green;
    }
}
